Repository navigation
Conversation
The fee bumps of one channel take turns, so that a second offer does not reach a close that waits for the peer's signature of the first, which stops the closer. A bump gave up its turn as soon as its offer was sent. Sending only queues the offer: when the closer is busy with another event at that moment, the next bump can still read the state from before the offer, and send its own. A bump now keeps its turn until the close shows a new local state, which only a local offer causes, or until the caller or the peer goes away, the closer stops or the close leaves negotiation. sendRbfCloseEvent reports whether it sent the event, so a bump whose closer was retired does not wait. A channel's turn is no longer kept after the last bump that uses it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardening follow-up to #23, requested in review: the approach was proposed in this comment, and the PR asked for as hardening in this one. The fee bumps of one channel take turns, but a bump gave up its turn as soon as its offer was sent, which only queues it. A bump now keeps its turn until the close has taken the offer, so the next bump cannot read the state from before it and send a second offer into
LocalOfferSent. The turns map also drops a channel's entry after its last bump.Problem
sendRbfFeeBump(peer/brontide.go:5222) releases the turn when it returns, right afterSendEvent. If the closer is busy with another event at that moment, in practice a peer message, the offer waits in the event buffer and the next bump'sCurrentState()can be answered first. That bump then sends its own offer intoLocalOfferSent: the closer sends the peer anerrorand resets, so the bump fails and the close can be retried. Nothing is at risk, and an idle closer takes the event at once (0 stale reads in 3000 tries), so this is hardening rather than a fix for an observed failure.Reproduction
The test holds the closer inside the signer, in the middle of the offer, and checks that the turn is not free. It tests the property, not an observed failure: two concurrent bumps on a close that can sign ran 300 times without a double offer.
Before
On
blake2b6deb6c9 the new test fails 5 of 5:Change
sendRbfFeeBumpsubscribes to the closer's states before it sends the offer, and keeps the turn until the close shows a new local state (waitRbfOfferTaken). Only a local offer replaces the local state: an event for the remote party keeps it, and the only other sender ofSendOfferEventis the closer's own first offer atChannelFlushed.sendRbfCloseEventreports whether it sent the event, so a bump whose closer was retired does not wait.waitUntilRbfCoastClearreturns the local state it saw.rbfFeeBumpSlotscounts the bumps that hold or wait for a channel's turn and drops the entry when none is left.After
The new test passes 10 of 10 under
-race, with theTestRbfReconnect*tests andTestRbfFeeBumpSlots.Test results
Commit
201d11280onblake2b6deb6c9.peer,protofsmandlnwallet/chancloserpass under-race; gofmt and vet with and without the dev and RPC tags are clean.rbf_coop_closeandrbf_coop_close_disconnectpass.Caveats
startRbfChanCloserhas the same small window for twoCloseChannelcalls sent back to back on an active channel. This change does not cover it.